/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * FenChoixClasses.java
 *
 * Created on 15 janv. 2012, 18:19:15
 */
package InterfaceGraphique.popupChoix;

import InterfaceGraphique.BoiteMessage;
import InterfaceGraphique.commonPannel.PanListeCarte;
import cartes.Carte;
import common.Constantes;
import comportement.ActionPerdreClasse;
import java.util.ArrayList;
import plateau.Joueur;

/**
 *
 * @author Arthur
 */
public class FenChoixClasses extends javax.swing.JFrame {

    private ActionPerdreClasse act; 
    private Joueur j;
    
    /** Creates new form FenChoixClasses */
    public FenChoixClasses() {
        this.pCartesClasses = new PanListeCarte("Equipement :", 1160, 240, Constantes.PAN_EQUIP, this);
        this.add(pCartesClasses, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 690));
        
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        bValider = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setAlwaysOnTop(true);
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        bValider.setText("Valider");
        bValider.setName("bValider"); // NOI18N
        bValider.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bValiderActionPerformed(evt);
            }
        });
        getContentPane().add(bValider, new org.netbeans.lib.awtextra.AbsoluteConstraints(300, 280, -1, -1));

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-700)/2, (screenSize.height-350)/2, 700, 350);
    }// </editor-fold>//GEN-END:initComponents

    private void bValiderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bValiderActionPerformed
        // TODO add your handling code here:
        Carte c;
        if( (c = this.pCartesClasses.getSelected()) != null) {
            act.choixCarte(j, c);
        }
        else 
            new BoiteMessage("Veuillez choisir une carte");
    }//GEN-LAST:event_bValiderActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(FenChoixClasses.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(FenChoixClasses.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(FenChoixClasses.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(FenChoixClasses.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new FenChoixClasses().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton bValider;
    // End of variables declaration//GEN-END:variables
    private PanListeCarte pCartesClasses;
    
    public void load( ActionPerdreClasse act, Joueur j, ArrayList<Carte> cartes ) {
        this.act = act;
        this.j = j;
        this.pCartesClasses.setCartes(cartes, true);
    } 
}
